/**
 * 表格配置
 * 系统配置 system-config
 */

const isHidden = (list, row) => {
  const { isEdit } = row || {}
  return list.includes(String(isEdit))
}

const headerConfig = {
  'system-config': [
    {
      prop: 'label',
      name: '键',
      minWidth: 110
    },
    {
      prop: 'value',
      name: '值',
      minWidth: 133
    },
    {
      prop: 'remark',
      name: '描述',
      minWidth: 100
    },
    {
      prop: 'isEditName',
      name: '是否允许修改',
      minWidth: 100
    },

    {
      prop: 'status',
      name: '状态',
      componentCell: 'CellSwitch',
      authId: 'grass-core:config:update',
      switchConfig: {
        valueTypeProp: 'code',
        dataProp: 'status',
        activeCode: 1,
        activeName: '启用',
        inactiveCode: 2,
        inactiveName: '禁用',
        switchPath: 'systemConfig.enableOrDisable',
        switchParamsProp: {
          id: 'id',
          label: 'label',
          value: 'value',
          sort: 'sort',
          dictCode: 'dictCode',
          remark: 'remark',
          name: 'name'
        }
      }
    },
    {
      name: '操作',
      width: 200,
      fixed: 'right',
      thStyle: { 'text-align': 'left' },
      operateList: [
        {
          type: 'btnText',
          label: '编辑',
          id: 'system-config-edit',
          authId: 'grass-core:config:update',
          config: { type: 'text' },
          style: { color: 'rgb(219,139,57)' },
          hidden: (val) => {
            return !isHidden(['1'], val)
          }
        },
        {
          type: 'btnText',
          label: '删除',
          id: 'system-config-delete',
          authId: 'grass-core:config:deleteById',
          isMore: true,
          config: { type: 'text' },
          style: { color: '#ff0000' },
          hidden: (val) => {
            return !isHidden(['1'], val)
          }
        }
      ]
    }
  ]
}

export default {}
export { headerConfig }
